<template>
  <div>
    <div>
      <el-button type="primary" @click="show3">初始化基本视频</el-button>
      <el-button type="primary" @click="close3">关闭基本视频</el-button>
    </div>
    <div style="margin-left: 8px; display: inline-block">
      <div>
        <BaseFlvPlayer
          ref="player3"
          v-bind:supportDrag="true"
          :posterUrl="require('../../assets/logo.png')"
          :is-show="isShow"
          @player-closed="_close"
        >
          <template v-slot:custom-cover>
            <SimplePlayerControls></SimplePlayerControls>
          </template>
        </BaseFlvPlayer>
      </div>
    </div>
  </div>
</template>
  
<script>
import BaseFlvPlayer from "@/components/player/BaseFlvPlayer";
import SimplePlayerControls from "@/components/player/SimplePlayerControls";
export default {
  components: {
    BaseFlvPlayer,
    SimplePlayerControls,
  },
  data() {
    return {
      isShow: true,
    };
  },
  mounted() {},
  methods: {
    // show0() {
    //   this.$refs.player0.open({
    //     type: "flv",
    //     enableWorker: true, //浏览器端开启flv.js的worker,多进程运行flv.js
    //     isLive: true,
    //     hasAudio: false,
    //     stashInitialSize: 128,
    //     enableStashBuffer: false, //播放flv时，设置是否启用播放缓存，只在直播起作用。
    //     url: "https://flvopen.ys7.com:9188/openlive/0064df87febe48da91db6f13ee03be3d.hd.flv",
    //   });
    // },
    // show1() {
    //   this.$refs.player1.addEventListener("play", (info) => {
    //     console.log("==========>play", info);
    //   });
    //   this.$refs.player1.open({
    //     type: "flv",
    //     enableWorker: true, //浏览器端开启flv.js的worker,多进程运行flv.js
    //     isLive: true,
    //     hasAudio: false,
    //     stashInitialSize: 128,
    //     enableStashBuffer: false, //播放flv时，设置是否启用播放缓存，只在直播起作用。
    //     url: "http://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-720p.flv",
    //   });
    // },
    // show2() {
    //   this.$refs.player2.open({
    //     type: "mp4",
    //     url: "http://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4",
    //   });
    // },
    show3() {
      this.$refs.player3.load({
        type: "mp4",
        hasAudio: false,
        muted: true,
        url: "http://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4",
      });
    },
    close3() {
      this.$refs.player3.close();
    },
    _close() {
      console.log("视频关闭了");
      this.isShow = false;
    },
  },
};
</script>
  
<style lang="scss" scoped>
</style>
